<template>
	<!-- 我的等级 -->
	<view>
		<!-- #ifdef MP -->
		<NavBar titleText="创业合伙人" :iconColor="iconColor" :textColor="iconColor" :isScrolling="scrollY>10 ? true : false"  showBack></NavBar>
		<!-- #endif -->
		<view class="vip_image">
			<image class="vipimage01" :src="imgHost+'/static/images/vipnew.jpg'" mode=""></image>
			<view class="vipbtn" @click="pay">
				10000立即开通
			</view>
		</view>
		
	</view>
</template>

<script>
	import colors from '@/mixins/color.js';
	import {
		mapGetters
	} from "vuex";
	import {
		memberCard,
		memberCardDraw,
		memberCardCreate,
		groomList,
		memberOverdueTime
	} from '@/api/user.js';
	import {
		orderOfflinePayType
	} from '@/api/order.js';
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		openPaySubscribe
	} from '@/utils/SubscribeMessage.js';
	import dayjs from '@/plugin/dayjs/dayjs.min.js';
	import recommend from '@/components/recommend/index.vue';
	import home from '@/components/home/index.vue';
	
	import NavBar from '@/components/NavBar';
	import {
		HTTP_REQUEST_URL
	} from '@/config/app.js';
	export default {
		components: {
			recommend,
			NavBar
		},
		data() {
			return {
				// #ifdef MP
				iconColor: '#000000',
				isScrolling: true,
				// #endif
				scrollY: 0, //页面滚动高度
				
				// #ifdef H5
				isWeixin: this.$wechat.isWeixin(),
				// #endif
				type: '',
				svip: {},
				isShowAuth: false,
				
				imgHost:HTTP_REQUEST_URL,
				
			};
		},
		computed: mapGetters(['isLogin']),
		onLoad() {
			
		},
		onShow() {
			
		},
		onPageScroll(e) {
			this.scrollY = e.scrollTop;
		},
		methods: {
			tabfun(i){
				this.tabindex = i
			},
			goLogin(){
				toLogin();
			},
			// 卡密兑换
			drawMemberCard() {
				if(this.isLogin){
					uni.navigateTo({
						url: '/pages/annex/vip_paid_active/index'
					})
				}else{
					toLogin();
				}
			},
			getMemberCard() {
				memberCard().then(res => {
					let data = res.data;
					this.memberType = data.member_type;
					this.memberRights = data.member_rights;
					this.isGetFree = data.is_get_free;
				}).catch(err => {
			
				});
			},
			onLunch() {
				this.memberCard();
				this.groomList();
			},
			// 立即开通
			pay() {
				this.createMemberCard('weixin');
			},
			// 立即购买
			createMemberCard(type) {
				uni.showLoading({
					title: '正在加载…'
				});
				let query = {
					pay_type: type || this.payMode[0].value,
					type: '1',
					// #ifdef H5
					from: this.isWeixin ? 'weixin' : 'weixinh5',
					// #endif
					// #ifdef MP
					from: 'routine',
					// #endif
					// #ifdef APP-PLUS
					from: 'weixin',
					// #endif
					// member_type: this.svip.id,
					// price: this.svip.pre_price,
					// money: this.svip.price,
					member_type: 4,
					price: 10000,
					money: 10000,
					// #ifdef H5
					quitUrl: location.port ? location.protocol + '//' + location.hostname + ':' + location.port +
						'/pages/annex/vip_paid/index' : location.protocol + '//' + location.hostname +
						'/pages/annex/vip_paid/index'
					// #endif
				};
				// #ifdef MP
				openPaySubscribe().then(() => {
					memberCardCreate(query).then(res => {
						uni.hideLoading()
						uni.redirectTo({
							url: `/pages/goods/cashier/index?order_id=${res.data.order_id}&from_type=vip`
						})
					}).catch(err => {
						uni.showToast({
							title: err
						});
					});
				});
				// #endif
				// #ifndef MP
				memberCardCreate(query).then(res => {
					uni.hideLoading()
					uni.redirectTo({
						url: `/pages/goods/cashier/index?order_id=${res.data.order_id}&from_type=vip`
					})
				}).catch(err => {
					uni.showToast({
						title: err,
						icon: 'none'
					});
				});
				// #endif
			},
			
			getMemberCard() {
				memberCard().then(res => {
					let data = res.data;
					this.memberType = data.member_type;
					this.memberRights = data.member_rights;
					this.isGetFree = data.is_get_free;
				}).catch(err => {
			
				});
			},
			memberSelect(index) {
				this.memberSelected = index;
			},
			// 付费会员数据
			memberCard() {
				uni.showLoading({
					title: '正在加载…'
				});
				memberCard().then(res => {
					uni.hideLoading();
					const {
						is_get_free,
						member_coupons,
						member_explain,
						member_rights,
						member_type
					} = res.data;
					this.isGetFree = is_get_free;
					this.userInfo = is_get_free.user_info;
					this.memberRights = member_rights;
					this.memberType = member_type;
					this.memberCoupons = member_coupons;
					this.memberExplain = member_explain;
					if (is_get_free.is_record) {
						this.memberType = this.memberType.filter(item => item.type !== 'free');
					};
					this.totalPrice = parseFloat(this.memberType[0].pre_price);
					this.type = this.memberType[0].type;
					this.totalPrice = parseFloat(this.memberType[0].pre_price);
					this.svip = this.memberType[0];
					memberOverdueTime({
						member_type: this.svip.type,
						vip_day: this.svip.vip_day
					}).then(res => {
						this.memberEndTime = res.data.data;
					});
				}).catch(err => {
					uni.showToast({
						title: err,
						icon: 'none'
					});
				});
			},
			groomList() {
				if (this.finished) {
					return;
				}
				uni.showLoading({
					title: '加载中'
				});
				groomList(5, {
					page: this.page,
					limit: this.limit
				}).then(res => {
					uni.hideLoading();
					this.goodsList = this.goodsList.concat(res.data.list);
					this.finished = res.data.list.length < this.limit;
					this.page += 1;
				}).catch(err => {
					uni.hideLoading();
				});
			},
		},
		onReachBottom() {
			
		}
	}
</script>

<style lang="scss" scoped>
	.vip_image{
		width: 100%;
		height: auto;
		position: relative;
	}
	.vipimage01{
		position: absolute;
		width: 100%;
		height: 2200rpx;
		top: 0;
		left: 0;
		z-index: -1;
	}
	.vipbtn{
		width: 630rpx;
		height: 80rpx;
		border-radius: 60rpx;
		background: rgba(0, 179, 239, 1);
		position: fixed;
		bottom:60rpx;
		left: 60rpx;
		font-size: 32rpx;
		font-weight: 400;
		line-height: 80rpx;
		color: rgba(255, 255, 255, 1);
		text-align: center;
	}
</style>